function rowStyle(row, index) {
  var classes = ['active', 'success', 'info', 'warning', 'danger'];

  if (index % 2 === 0 && index / 2 < classes.length) {
    return {
      classes: classes[index / 2]
    };
  }
  return {};
}


$(document).ready(function () {
  var _maxHeight = $container().height();


  $('#btnAdd').click(function () {
    $('#modal-form').modal({
      show: true,
      backdrop: false
    });
  });

  $('#modal-form').on('hide.bs.modal', function () {
    alert('关闭模态窗口!');
  });

  $('#table').bootstrapTable({
    url: _CTX_ + '/static/json/table_data.json',
    method: 'get',
    height: _maxHeight - 210,
    pagination: true,
    pageNumber: 1,
    pageSize: 20,
    pageList: [20, 50, 100],
    clickToSelect: true,
    detailView: true,
    columns: [{
      radio: true
    }, {
      field: 'name',
      title: '姓名'
    }, {
      field: 'star',
      title: '关注度'
    }, {
      field: 'license',
      title: '许可方式'
    }, {
      field: 'description',
      title: '描述'
    }, {
      field: 'url',
      title: '链接地址',
      visible: false
    }, {
      title: '操作',  
      events: {'click .refreshChild': function(e, value, row, index){
        $("#sub_" + row.name).bootstrapTable('refresh');
      }},  
      formatter: function(value, row, index){
          return '<button id="btn_refresh" type="button" class="refreshChild btn-default bt-select">刷新</button>'
      }  
    }],
    onExpandRow: function (index, row, $detail) {
      $table = $('<table id="sub_' + row.name + '"></table>');
      $detail.append($table);
      $table.bootstrapTable({
        url: _CTX_ + '/static/json/table_data.json',
        method: 'get',
        pagination: true,
        pageNumber: 1,
        pageSize: 5,
        clickToSelect: true,
        columns: [{
          radio: true
        }, {
          field: 'name',
          title: '姓名'
        }, {
          field: 'star',
          title: '关注度'
        }, {
          field: 'license',
          title: '许可方式'
        }, {
          field: 'description',
          title: '描述'
        }, {
          field: 'url',
          title: '链接地址',
          visible: false
        }]
      })
    }
  })

})